package compro.admission.form.util;

import java.security.SecureRandom;

public class PasswordGenerator {
	public static final int PASSWORD_LENGTH = 8;

	public static String generatePassword() {
		String allowedCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
		SecureRandom random = new SecureRandom();
		StringBuffer password = new StringBuffer();

		for (int i = 0; i < PASSWORD_LENGTH; i++) {
			int position = random.nextInt(allowedCharacters.length());
			password.append(allowedCharacters.charAt(position));
		}
		return password.toString();
	}
}
